package com.ddone.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author ddone
 * @date 2024/3/27-10:56
 */
@Configuration
// @EnableSwagger2
@EnableOpenApi
public class SwaggerConfig {

    @Bean
    public Docket docket(){
       return new Docket(DocumentationType.SWAGGER_2)
               .groupName("SwaggerDemo")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ddone.controller"))
               // .paths() 路径过滤
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                // 文档标题
                .title("SwaggerDeMO")
                .description("整合到SpringBoot")
                .contact(new Contact("ddone","https://www.ddone.com","ddone@126.com"))
                .version("1.0")
                .build();
    }
}
